from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.select import Select
from selenium.webdriver import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from waiting import get_element

class TestLogin:
    def test_password_error(self):

    # 用例一：登录失败，密码错误
        driver = webdriver.Chrome()
        driver.get('http://192.168.234.137/index.php/Home/user/login.html')
        driver.maximize_window()
        get_element(driver,By.ID,"username").send_keys("13800138006")
        get_element(driver,By.ID,"password").send_keys("12356")
        get_element(driver,By.ID,"verify_code").send_keys("8888")
        get_element(driver,By.NAME,"sbtbutton").click()

        assert '密码错误!' == get_element(driver,By.CLASS_NAME,'layui-layer-content').text

    def test_verify_error(self):
        # 用例二：登录失败，验证码错误
        driver = webdriver.Chrome()
        driver.get('http://192.168.234.137/index.php/Home/user/login.html')
        driver.maximize_window()

        # 验证码错误
        get_element(driver,By.ID,"username").send_keys("13800138006")
        get_element(driver,By.ID,"password").send_keys("123456")
        get_element(driver,By.ID,"verify_code").send_keys("888")
        get_element(driver,By.NAME,"sbtbutton").click()

        assert '验证码错误' == get_element(driver,By.CLASS_NAME,'layui-layer-content').text
